//
//  profressview.m
//  SaIios
//
//  Created by Xiu on 2018/6/4.
//  Copyright © 2018年 金鑫. All rights reserved.
//

#import "profressview.h"

@implementation profressview

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        CGRect  viewFrame = CGRectMake(0, 0, 0, frame.size.height);
        UIView *view = [[UIView alloc]initWithFrame:viewFrame];
        [self addSubview:view];
        view.backgroundColor = [UIColor clearColor];
        self.progressView = view;
    }
    return self;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    
    CGRect  viewFrame = CGRectMake(0, 0, 0, self.frame.size.height);
    UIView *view = [[UIView alloc]initWithFrame:viewFrame];
    [self addSubview:view];
    view.backgroundColor = [UIColor clearColor];
    self.progressView = view;
}

-(void)setProgress:(CGFloat)progress{
    
    _progress = progress;
    if (progress == 0) {
        self.progressView.backgroundColor = [UIColor clearColor];
    }else{
        self.progressView.backgroundColor = [UIColor redColor];
        
        CGRect frame = CGRectMake(0, 0, self.frame.size.width * progress, self.frame.size.height);
        
        [UIView animateWithDuration:1.5 animations:^{
            
            self.progressView.frame = frame;
            
        }];
        
    }
    
}
@end
